import 'package:flutter/material.dart';

//接受上个页面传递过来的参数
class Newspage extends StatefulWidget {
  final String title;
  final int aid;
 
  const Newspage({super.key, this.title = '新闻', required this.aid});

  @override
  State<Newspage> createState() => _NewspageState();
}

class _NewspageState extends State<Newspage> {
  @override
  void initState() {
    super.initState();
    print(widget.aid);
    print(widget.title);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('新闻')), //获取NewsPage传递的title
      body: Center(child: Text(widget.title)),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Navigator.pop(context);
        },
        child: Icon(Icons.home),
      ),
    );
  }
}
